/**
 *@description 当前时间 12:01:01
 */
export const formatTime = (time) => {
	if (typeof time !== 'number' || time < 0) {
		return time
	}

	var hour = parseInt(time / 3600)
	time = time % 3600
	var minute = parseInt(time / 60)
	time = time % 60
	var second = time

	return ([hour, minute, second]).map(function(n) {
		n = n.toString()
		return n[1] ? n : '0' + n
	}).join(':')
}
/**
 *@description 位置
 */
export const formatLocation = (longitude, latitude) => {
	if (typeof longitude === 'string' && typeof latitude === 'string') {
		longitude = parseFloat(longitude)
		latitude = parseFloat(latitude)
	}

	longitude = longitude.toFixed(2)
	latitude = latitude.toFixed(2)

	return {
		longitude: longitude.toString().split('.'),
		latitude: latitude.toString().split('.')
	}
}

/**
 *@description 格式日期
 */
export const formatDate = (date) => {
	var dateTime = new Date(date);
	var year = dateTime.getFullYear();
	var month = dateTime.getMonth() + 1;
	var day = dateTime.getDate();
	return [year, month, day].join('/');
}
/**
 *@description 下几年
 */
export const getDateNextYear = (n = 1) => {
	var dateTime = new Date();
	dateTime = dateTime.setFullYear(dateTime.getFullYear() + n);
	dateTime = new Date(dateTime);
	return formatDate(dateTime);
}
/**
 * @description 下几月
 */
export const getDateNextMonth = (n = 1) => {
	var dateTime = new Date();
	dateTime = dateTime.setMonth(dateTime.getMonth() + n);
	dateTime = new Date(dateTime);
	return formatDate(dateTime);
}
/**
 *@description 今天
 */
export const getDateToday = () => {
	var dateTime = new Date();
	return formatDate(dateTime);
}
/**
 * 判断是否为空
 */
export const isNull = (val) => {
	var res = false;
	if (typeof(val) == undefined)
		res = true;
	if (val == null)
		res = true;
	if (val == "")
		res = true;
	return res;
}
